package com.oujiong.sharding.algorithm;

import com.google.common.collect.Range;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue;

import java.util.ArrayList;
import java.util.Collection;

public class MyRangeShardingAlgorithm  implements RangeShardingAlgorithm<Long> {

    @Override
    public Collection<String> doSharding(Collection<String> collection,
                                         RangeShardingValue<Long> rangeShardingValue) {
        /*Collection<String> collect = new ArrayList<>();
        Range<Long> valueRange = rangeShardingValue.getValueRange();
        long start=Long.valueOf(valueRange.lowerEndpoint()+"");
        long end=Long.valueOf(valueRange.upperEndpoint()+"");
        for (long i = start; i <= end; i++) {
            for (String each : collection) {
                if (each.endsWith(i % collection.size() + "")) {
                    collect.add(each);
                }
            }
        }*/
        return collection;//全库路由处理
    }
}
